﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ColorWheelNET
{
    public partial class ColorWheelDialog : Form
    {
        public ColorWheelDialog()
        {
            InitializeComponent();
            SetSelectedWheelOption(ColorWheelDisplayStyle.ColorWheel);
        }

        public ColorWheelDialog(ColorWheelDisplayStyle style)
        {
            InitializeComponent();
            SetSelectedWheelOption(style);
        }

        /// <summary>
        /// Get Selected Color
        /// </summary>
        public Color SelectedColor
        {
            get
            {
                return colorWheel1.Color;
            }
            set { colorWheel1.Color = value; }
        }

        private ToolStripButton _selectedOption;

        // Set this method public
        // If users want to pick which wheel to show at start up, they can use this method
        /// <summary>
        /// Sets the DisplayStyle of the ColorWheel on the dialog
        /// </summary>
        /// <param name="style">The desired display style</param>
        public void SetSelectedWheelOption(ColorWheelDisplayStyle style)
        {
            if (_selectedOption != null)
            {
                _selectedOption.Checked = false;
            }
            
            switch (style)
            {
                case ColorWheelDisplayStyle.ColorWheel:
                    _selectedOption = tsbSatWheel;
                    break;
                case ColorWheelDisplayStyle.DarkColorWheel:
                    _selectedOption = tsbValueWheel;
                    break;
                case ColorWheelDisplayStyle.Rectangle:
                    _selectedOption = tsbRectWheel;
                    break;
                case ColorWheelDisplayStyle.HSVTriangle:
                    _selectedOption = tsbTriangleWheel;
                    break;

                default:
                    _selectedOption = tsbSatWheel;
                    break;
            }

            colorWheel1.DisplayStyle = style;
            _selectedOption.Checked = true;
        }

        private void btnOkay_Click(object sender, EventArgs e)
        {
            //colorWheel1.Color = colorWheel1.Color;
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void tsbSatWheel_Click(object sender, EventArgs e)
        {
            SetSelectedWheelOption(ColorWheelDisplayStyle.ColorWheel);
        }

        private void tsbValueWheel_Click(object sender, EventArgs e)
        {
            SetSelectedWheelOption(ColorWheelDisplayStyle.DarkColorWheel);
        }

        private void tsbRectWheel_Click(object sender, EventArgs e)
        {
            SetSelectedWheelOption(ColorWheelDisplayStyle.Rectangle);
        }

        private void tsbTriangleWheel_Click(object sender, EventArgs e)
        {
            SetSelectedWheelOption(ColorWheelDisplayStyle.HSVTriangle);
        }

    }
}
